using System;
using DevExpress.Xpo;
using DevExpress.Data.Filtering;
using System.Linq;

namespace NetworkSupervisor.Model.NetworkSupervisor
{
    public partial class taQQ列表
    {
        public taQQ列表(Session session) : base(session)
        {
        }

        public taQQ列表() : base(Session.DefaultSession)
        {
        }


        public override void AfterConstruction()
        {
            base.AfterConstruction();
        }

        /// <summary>
        /// 设置在线次数
        /// </summary>
        /// <returns></returns>
        public void Set在线次数()
        {
            CriteriaOperator op = CriteriaOperator.Parse(string.Format("QQ='{0}' AND 在线状态=1", QQ));
            XPCollection<taQQ在线纪录> collection = new XPCollection<taQQ在线纪录>(Session, op, null);
            在线次数 = collection.Count;
        }

        /// <summary>
        /// 设置上次在线时间
        /// </summary>
        /// <returns></returns>
        public void Set上次在线时间()
        {
            CriteriaOperator op = CriteriaOperator.Parse(string.Format("QQ='{0}' AND 在线状态=1", QQ));
            XPCollection<taQQ在线纪录> collection = new XPCollection<taQQ在线纪录>(Session, op, null);
            taQQ在线纪录 item = collection.OrderByDescending(o => o.在线时间).FirstOrDefault();
            if (item != null) 上次在线时间 = item.在线时间;
            else 上次在线时间 = null;
        }
    }
}